


clear all 
use the_dataset.dta

keep if  standard == 1

global covariates1 culture1 educ_basic1-educ_sup1 age051-age661 income1 NMIEMB1 size_dummy1-size_dummy5 number_spanish1
global covariates2 culture1 educ_basic1-educ_sup1 age051-age661 income1 NMIEMB1 size_dummy1-size_dummy5 number_spanish1 ccaadummy1-ccaadummy17 
global covariates3 culture1 educ_basic1-educ_sup1 age051-age661 income1 NMIEMB1 size_dummy1-size_dummy5 number_spanish1 ccaadummy1-ccaadummy17 yeardummy1-yeardummy9


* 1.0 Gen participation
gen c_c1 = 1 if culture1 > 0
gen c_c2 = 1 if culture2 > 0
replace c_c2 = 0 if culture2 == 0



* 2.1 Estimate Participation T01
preserve
keep if case_1 == 1
*Sdid
absdid c_c2 , tvar(unemp) xvar($covariates3) sle 
eststo C1
* Matching
teffects nnmatch (c_c2 $covariates1) (unemp), ematch(ANOENC1 CCAA1) nneighbor(3) atet biasadj($covariates1)
eststo C2
* Trimmed
gen var = _n
merge 1:1 var using "part_cop_t01.dta"
drop _merge
keep if (part_culture_1==1 | unemp==1)
teffects nnmatch (c_c2 $covariates2) (unemp), ematch(ANOENC1) nneighbor(3) atet biasadj($covariates2)
eststo D2
restore

*2.2 Estimate expenditure T01
preserve
keep if case_1 == 1 & c_c2 == 1
*Sdid
absdid culture_d , tvar(unemp) xvar($covariates3) sle 
eststo C3
matrix sp1_c = e(b)
scalar sp1_c = sp1_c[1,1]
* Matching
teffects nnmatch (culture_d $covariates2) (unemp), ematch(ANOENC1) nneighbor(3) atet biasadj($covariates2)
eststo C4
matrix mm1_c = e(b)
scalar mm1_c = mm1_c[1,1]
* Trimmed
gen var = _n
merge 1:1 var using "exp_cop_t01.dta"
drop _merge
keep if (mes_culture_1==1 | unemp==1)
teffects nnmatch (culture_d $covariates2) (unemp), ematch(ANOENC1) nneighbor(3) atet biasadj($covariates2)
eststo D4
matrix mmt1_c = e(b)
scalar mmt1_c = mmt1_c[1,1]
restore

*2.3 Estimate income T01
preserve
keep if case_1==1  & c_c2 == 1
*Sdid
absdid income_d, tvar(unemp) xvar($covariates3) sle 
eststo C5
matrix sp1_c_inc = e(b)
scalar sp1_c_inc = sp1_c_inc[1,1]
* Matching
teffects nnmatch (income_d $covariates2) (unemp), ematch(ANOENC1) nneighbor(3) atet biasadj($covariates2)
eststo C6
matrix mm1_c_inc = e(b)
scalar mm1_c_inc = mm1_c_inc[1,1]
* Trimmed
gen var = _n
merge 1:1 var using "exp_cop_t01.dta"
drop _merge
keep if (mes_culture_1==1 | unemp==1)
teffects nnmatch (income_d $covariates2) (unemp), ematch(ANOENC1) nneighbor(3) atet biasadj($covariates2)
eststo D6
matrix mmt1_c_inc = e(b)
scalar mmt1_c_inc = mmt1_c_inc[1,1]
restore

* Estimate elasticity T01
preserve
* mean values
sum culture2 if case_1 == 1 & unemp==1 & c_c2 == 1
scalar c1_mean = r(mean)
sum income2  if case_1 == 1 & unemp==1 & c_c2 == 1
scalar inc_c1_mean = r(mean)

* expenditure
gen sp1_c = sp1_c
gen mm1_c = mm1_c
gen mmt1_c = mmt1_c

* income
gen sp1_c_inc = sp1_c_inc
gen mm1_c_inc = mm1_c_inc
gen mmt1_c_inc = mmt1_c_inc

*
gen     c1_ = (2*c1_mean)
gen inc_c1_ = (2*inc_c1_mean)

gen c1_sp  = c1_ - sp1_c
gen c1_mm  = c1_ - mm1_c
gen c1_mmt = c1_ - mmt1_c

gen inc_c1_sp  = inc_c1_ - sp1_c_inc
gen inc_c1_mm  = inc_c1_ - mm1_c_inc
gen inc_c1_mmt = inc_c1_ - mmt1_c_inc

* elasticity

gen elast_c1_sp = (sp1_c / sp1_c_inc) / (c1_sp / inc_c1_sp)
gen elast_c1_mm = (mm1_c / mm1_c_inc) / (c1_mm / inc_c1_mm)
gen elast_c1_mmt = (mmt1_c / mmt1_c_inc) / (c1_mmt / inc_c1_mmt)
sum elast_c1_sp elast_c1_mm elast_c1_mmt
restore



* 3 Estimate Participation T12
preserve
keep if case_2 == 1
*Sdid
absdid c_c2 , tvar(unemp) xvar($covariates3) sle 
eststo C1
* Matching
teffects nnmatch (c_c2 $covariates2) (unemp), ematch(ANOENC1) nneighbor(3) atet biasadj($covariates2)
eststo C2
* Trimmed
gen var = _n
merge 1:1 var using "part_cop_t12.dta"
drop _merge
keep if (part_culture_2==1 | unemp==1)
teffects nnmatch (c_c2 $covariates2) (unemp), ematch(ANOENC1) nneighbor(3) atet biasadj($covariates2)
eststo D2
restore

*3.2 Estimate expenditure T12
preserve
keep if case_2 == 1 & c_c2 == 1
*Sdid
absdid culture_d , tvar(unemp) xvar($covariates3) sle 
eststo C3
matrix sp1_c = e(b)
scalar sp1_c = sp1_c[1,1]
*Matching
teffects nnmatch (culture_d $covariates2) (unemp), ematch(ANOENC1) nneighbor(3) atet biasadj($covariates2)
eststo C4
matrix mm1_c = e(b)
scalar mm1_c = mm1_c[1,1]
* Trimmed
gen var = _n
merge 1:1 var using "exp_cop_t12.dta"
drop _merge
keep if (mes_culture_2==1 | unemp==1)
teffects nnmatch (culture_d $covariates2) (unemp), ematch(ANOENC1) nneighbor(3) atet biasadj($covariates2)
eststo D4
matrix mmt1_c = e(b)
scalar mmt1_c = mmt1_c[1,1]
restore

*3.3 Estimate income T12
preserve
keep if case_2==1  & c_c2 == 1
*Sdid
absdid income_d, tvar(unemp) xvar($covariates3) sle 
eststo C5
matrix sp1_c_inc = e(b)
scalar sp1_c_inc = sp1_c_inc[1,1]
*Matching
teffects nnmatch (income_d $covariates2) (unemp), ematch(ANOENC1) nneighbor(3) atet biasadj($covariates2)
eststo C6
matrix mm1_c_inc = e(b)
scalar mm1_c_inc = mm1_c_inc[1,1]
* Trimmed
gen var = _n
merge 1:1 var using "exp_cop_t12.dta"
drop _merge
keep if (mes_culture_2==1 | unemp==1)
teffects nnmatch (income_d $covariates2) (unemp), ematch(ANOENC1) nneighbor(3) atet biasadj($covariates2)
eststo D6
matrix mmt1_c_inc = e(b)
scalar mmt1_c_inc = mmt1_c_inc[1,1]
restore

*3.4 Elasticity
preserve
sum culture2 if case_2 == 1 & unemp==1 & c_c2 == 1
scalar c1_mean = r(mean)

sum income2  if case_2 == 1 & unemp==1 & c_c2 == 1
scalar inc_c1_mean = r(mean)

* expenditure estimates 
gen sp1_c = sp1_c
gen mm1_c = mm1_c
gen mmt1_c = mmt1_c

* income estimates
gen sp1_c_inc = sp1_c_inc
gen mm1_c_inc = mm1_c_inc
gen mmt1_c_inc = mmt1_c_inc

* base levels 

gen     c1_ = (2*c1_mean)
gen inc_c1_ = (2*inc_c1_mean)

* OUTCOME - ATET: POTENTIAL OUTCOME 

gen c1_sp  = c1_ - sp1_c
gen c1_mm  = c1_ - mm1_c
gen c1_mmt = c1_ - mmt1_c

gen inc_c1_sp  = inc_c1_ - sp1_c_inc
gen inc_c1_mm  = inc_c1_ - mm1_c_inc
gen inc_c1_mmt = inc_c1_ - mmt1_c_inc

* ELASTICITY 

gen elast_c1_sp = (sp1_c / sp1_c_inc) / (c1_sp / inc_c1_sp)
gen elast_c1_mm = (mm1_c / mm1_c_inc) / (c1_mm / inc_c1_mm)
gen elast_c1_mmt = (mmt1_c / mmt1_c_inc) / (c1_mmt / inc_c1_mmt)

sum elast_c1_sp elast_c1_mm elast_c1_mmt




